package com.smart.persistence.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.TableGenerator;


@Entity
@Table(name = "T_Destination")
@NamedQueries({
    @NamedQuery(name = Destination.findByName, 
    		query = "SELECT  entity  FROM Destination entity where  upper(entity.name) LIKE upper(concat(concat('%',?1),'%'))"),
    		@NamedQuery(name = Destination.findByCodDestination, 
    	    		query = "SELECT  entity  FROM Destination entity where  entity.codDestination = ?1")    		
})	
public class Destination {
	
	public static final String findByName = "Destination.findByName";
	public static final String findByCodDestination= "Destination.findByCodDestination";
	
	@Id
	@Column(name = "id_destination")
	@TableGenerator(name = "DESTINATION_GEN", allocationSize = 1, initialValue = 1, table = "T_ID", pkColumnName = "key", 
			valueColumnName = "valor", pkColumnValue = "ID_DESTINATION")
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "DESTINATION_GEN")
	private long id;
	
	@Column(unique=true)
	private long codDestination;
	
	
	private String name;
	
	@ManyToMany(mappedBy="destinations")
    private List<Hotel> hoteis;


	public long getId() {
		return id;
	}


	public void setId(long id) {
		this.id = id;
	}


	


	public long getCodDestination() {
		return codDestination;
	}


	public void setCodDestination(long codDestination) {
		this.codDestination = codDestination;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public List<Hotel> getHoteis() {
		return hoteis;
	}


	public void setHoteis(List<Hotel> hoteis) {
		this.hoteis = hoteis;
	}
	
	
	
	



}
